<?php session_start(); ?>
<link href="css/login.css" rel="stylesheet" type="text/css">
<?php
	include("../asset/config/koneksi.php");
	$pass=md5($_POST['pass']);
	$login=mysql_query("select id_user, email, id_rs from user where email='$_POST[email]' and password='$pass' and aktivasi = 'Y' and level = 'O'");
	$ketemu=mysql_num_rows($login);
	$r=mysql_fetch_array($login);

	//apabila username ketemu
	if($ketemu > 0) {
		//daftarkan session ke server
		session_register("iduser");
		session_register("emailuser");
		session_register("idrs");
		
		//isi dari variabel session
		$_SESSION['iduser']=$r['id_user'];
		$_SESSION['idrs']=$r['id_rs'];
		$_SESSION['emailuser']=$r['email'];
	
		echo "<meta http-equiv='refresh' content='0; url=utama.php'>"; 
	}
	else {
		echo "<div id=gagal><b>Login gagal! Username atau Password tidak benar</b><br>";
		echo "<a href=index.php><b>ULANGI LAGI</b></a></div>"; 
	}
?>